home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 6 / FM Towns Free Software Collection 6.iso / ms_dos / cd_lib / src / cdr_mtrp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-08  |  1.7 KB  |  75 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <dos.h>
  4. #include "define.h"
  5. /* #include <cdrfrb.h> */
  6.  
  7. #ifdef DEBUG
  8. main(int argc, char *argv[])
  9. {
  10.     struct TIMEADRS time, end_time;
  11.     int i;
  12.     
  13.     if (argc > 1) {
  14.         printf("input is %s\n", argv[1]);
  15.         time.min = (u_char) atoi(argv[1]);
  16.         time.sec = 0;
  17.         time.frame = 0;
  18.         end_time.min = time.min;
  19.         end_time.sec = time.sec + 10;
  20.         end_time.frame = time.frame;
  21.         i = atoi(argv[2]);
  22.         printf("play %d分 %d回\n", time.min, i);
  23.         printf("return is %x\n", cdr_mtrplay(0, &time, &end_time, (u_char) i));
  24.     }
  25. }
  26. #endif
  27.  
  28. /* 音楽演奏スタート(時間指定 リピート回数指定) */
  29. /*
  30.  * decice_no:   device number (Towns CD-ROM -> 0)
  31.  * start_time: 演奏開始時間
  32.  * end_time: 演奏終了時間
  33.  * count: リピート回数
  34.  * return: 0 -> 正常終了, 0以外 -> エラー
  35.  */
  36. int cdr_mtrplay(int device_no, struct TIMEADRS *start_time, struct TIMEADRS *end_time, u_char count)
  37. {
  38.     union REGS reg;
  39.     struct SREGS seg;
  40.     char buf[6];
  41.     
  42.     if (start_time == NULL || end_time == NULL) {
  43.         return -1;
  44.     }
  45.  
  46.     reg.h.ah = 0x50;
  47.     reg.h.al = (0xC0 | (u_char) device_no);
  48.     reg.x.cx = 0xfe01;
  49.     reg.h.bh = count;
  50.  
  51.     buf[0] = start_time->min;    /* 分 */
  52.     buf[1] = start_time->sec;    /* 秒 */
  53.     buf[2] = start_time->frame;    /* フレーム */
  54.     buf[3] = end_time->min;    /* 分 */
  55.     buf[4] = end_time->sec;    /* 秒 */
  56.     buf[5] = end_time->frame;    /* フレーム */
  57.  
  58.     reg.x.di = (u_int) buf;
  59.     segread(&seg);
  60.     seg.ds = seg.ss;
  61.  
  62.     int86x(0x93, ®, ®, &seg);
  63.     
  64.     if (reg.h.ah == 0) {
  65.         return 0;
  66.     } else if (reg.h.ah == 0x02) {  /* device number error */
  67.         return DEVERR;
  68.     } else if (reg.h.ah == 0x10) {  /* cd-da plaing */
  69.         return DEVPLY;          
  70.     } else {                        /* (reg.h.ah == 0x80) hard ware error */
  71.         return reg.x.cx;
  72.     }
  73. }
  74.  
  75.